import re

def validate_id(id):
    if len(id) > 8:
        return False
    for ch in id:
        if not ch.isdigit() and not ch.isalpha() and ch !='_':
            return False
        return True
    
def validate_email(email):
        if '@' not in email:
            return False
        parts = email.split('@')
        if len(parts) !=2:
            return False
        if '_' not in parts[1]:
            return False
        return True

def validate_id_card(id_card):
    if len(id_card) != 18:
        return False
    if not id_card[:17].isdigit():
        return False
    if not (id_card[-1].isdigit() or id_card[-1] == 'X'):
        return False
    return True

def validate_name(name):
    if len(name) > 4:
        return False
    for ch in name:
        if not ('\u4e00' <= ch <= '\u9fff'):
            return False
        return True

def main():
    id = input("请输入ID:")
    if not validate_id(id):
        print("ID格式不正确")
        return
    email = input("请输入email地址:")
    if not validate_email(email):
        print("email地址格式不正确")
        return
    id_card = input("请输入身份证号:")
    if not validate_id_card(id_card):
        print("身份证号格式不正确")
        return
    name = input("请输入姓名")
    if not validate_name(name):
        print("姓名格式不正确")
        return
    print(f"注册成功！ \nID:{id}\nemail地址:{emall}\n身份证号:{id_card}\n姓名:{name}")

if __name__ == '__main__':
    main()











    
